<template>
    <div>
        <table  class="table table-border">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="data.name"></td>
                </tr>
                     <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="data.pwd"></td>
                </tr>
                     <tr>
                    <td><input type="button" value="登录" @click="deng()"></td>
                    <td></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { useUserInfoStore } from '@/stores/user';
import axios from 'axios';
import { ref} from 'vue'
import {useRoute,useRouter} from 'vue-router'
const router = useRouter();
const userStore = useUserInfoStore()

let data:any = ref({
    name:'',
    pwd:''
})
const deng=()=>{
    axios({
        url:'https://localhost:7035/api/Deng/GetDeng',
        method:'get',
        params:data.value
    })
    .then(res=>{
        if(res.data.did==-1)
        {
            alert('用户名不存在')
            return;
        }else
        if(res.data.did==-2)
        {
            alert('密码错误')
            return;
        }else
        if(res.data.did==-3)
        {
            alert('用户已冻结')
            return;
        }else
        {
           alert('登录成功')
           console.log(res)
           userStore.userInfo = res.data
           router.push("/demo2");
            
        }
    })
}
</script>

<style scoped>

</style>